def run_workflow(file_id, api_key):
    url = f"{DIFY_SERVER}/v1/workflows/run"
    headers = {"Authorization": f"Bearer {api_key}", "Content-Type": "application/json"}
    data = {
        "inputs": {
            "upload": {
                "type": "image",
                "transfer_method": "local_file",
                "upload_file_id": file_id,
            }
        },
        "user": USER,
        "response_mode": "blocking",
    }
    import pprint

    print("工作流调用参数：")
    pprint.pprint(data)
    response = requests.post(url, headers=headers, json=data)
    print("工作流返回内容：", response.status_code, response.text)
    if response.status_code == 200:
        resp_json = response.json()
        wf_status = resp_json.get("data", {}).get("status")
        if wf_status == "succeeded":
            outputs = resp_json.get("data", {}).get("outputs")
            print(f"[工作流执行成功] 文件ID: {file_id}")
            return resp_json, True, outputs
        else:
            error_info = resp_json.get("data", {}).get("error") or resp_json.get(
                "message"
            )
            print(f"[工作流内部失败] 文件ID: {file_id}，状态: {wf_status}")
            return resp_json, False, error_info
    else:
        print(
            f"[工作流执行失败] 文件ID: {file_id}，状态码: {response.status_code}，返回: {response.text}"
        )
        return (
            {
                "status": "error",
                "message": f"Failed to execute workflow, status code: {response.status_code}",
            },
            False,
            response.text,
        )
